package cn.iocoder.yudao.module.member.dal.mysql.job;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.controller.admin.job.vo.AppJobRespVO;
import cn.iocoder.yudao.module.member.controller.admin.job.vo.JobPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.job.ApiJobDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 职位 Mapper
 *
 * @author Alan
 */
@Mapper
public interface ApiJobMapper extends BaseMapperX<ApiJobDO> {

    default PageResult<ApiJobDO> selectPage(JobPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ApiJobDO>()
                .likeIfPresent(ApiJobDO::getJobName, reqVO.getJobName())
                .eqIfPresent(ApiJobDO::getCompanyId, reqVO.getCompanyId())
                .eqIfPresent(ApiJobDO::getMajorId, reqVO.getMajorId())
                .likeIfPresent(ApiJobDO::getMajorName, reqVO.getMajorName())
                .eqIfPresent(ApiJobDO::getClassRequirements, reqVO.getClassRequirements())
                .eqIfPresent(ApiJobDO::getMinEducation, reqVO.getMinEducation())
                .eqIfPresent(ApiJobDO::getProvinceId, reqVO.getProvinceId())
                .likeIfPresent(ApiJobDO::getProvinceName, reqVO.getProvinceName())
                .eqIfPresent(ApiJobDO::getCityId, reqVO.getCityId())
                .likeIfPresent(ApiJobDO::getCityName, reqVO.getCityName())
                .eqIfPresent(ApiJobDO::getDistrictId, reqVO.getDistrictId())
                .likeIfPresent(ApiJobDO::getDistrictName, reqVO.getDistrictName())
                .eqIfPresent(ApiJobDO::getAddress, reqVO.getAddress())
                .eqIfPresent(ApiJobDO::getJobDetail, reqVO.getJobDetail())
                .eqIfPresent(ApiJobDO::getIsShelved, reqVO.getIsShelved())
                .betweenIfPresent(ApiJobDO::getShelvedTime, reqVO.getShelvedTime())
                .eqIfPresent(ApiJobDO::getIsRecommend, reqVO.getIsRecommend())
                .betweenIfPresent(ApiJobDO::getRecommendTime, reqVO.getRecommendTime())
                .eqIfPresent(ApiJobDO::getVisitNum, reqVO.getVisitNum())
                .eqIfPresent(ApiJobDO::getSendNum, reqVO.getSendNum())
                .betweenIfPresent(ApiJobDO::getHireBeginTime, reqVO.getHireBeginTime())
                .betweenIfPresent(ApiJobDO::getHireEndTime, reqVO.getHireEndTime())
                .betweenIfPresent(ApiJobDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ApiJobDO::getId));
    }

    IPage<AppJobRespVO> getJobAddList(@Param("page") Page<AppJobRespVO> page,@Param("vo") JobPageReqVO pageReqVO);

    IPage<AppJobRespVO> getJobListPage(@Param("page")Page<AppJobRespVO> page,@Param("vo")  JobPageReqVO pageReqVO);

    List<Map> getJobListList(@Param("name")String name);
}